<?php
@session_start();
if (!isset($_SESSION['id_user']))
	//header('Location://localhost/firstclassapartmentscordoba/panel_control/login.php');
	//header('Location:http://firstclassapartment.com.ar/panel_control/login.php');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="es">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="Atenticaci&oacute;n | Panel de Control | First Class Apartments Cordoba Argentina">
		<meta name="author" content="Pulce Web Solutions - www.pulce.com.ar">
		<!--Para que las páginas se muestren correctamente y el zoom funcione bien en los dispositivos móviles-->
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="keywords" content="Departamento,Alquiler,Temporal,Cordoba,Capital,Argentina,First Class Apartments,Alojamiento,Turismo,Panel,Control,LogIn,Auenticaci&oacute;n">

		<title>Administrar Reservas | Panel de Control | First Class Apartments C&oacute;rdoba Argentina</title>

		<link href="../css/jquery.dataTables.css" rel="stylesheet">
		<link href="../css/dataTables.responsive.css" rel="stylesheet">
		<?php
			include_once('../links.php');
			include_once('menu_bar.php');
		?>
		<!--<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />-->
		<link href="../css/sunny/jquery-ui-1.10.4.custom.min.css" rel="stylesheet">

		<!--JQUERY-->
		<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
		<!--BOOTSTRAP-->
		<script src="../js/bootstrap.min.js"></script>
		<!--FUNCTIONS-->
		<script src="../js/functions.js"></script>
		<!--JQ-UI-->
		<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
		<!--DATEPICKER LANGUAJE-->
		<script src="../js/datapicker-languajes/jquery.ui.datepicker-es.js"></script>
		<!-- BACKSTRECH -->
		<script src="../js/jquery.backstretch.min.js"></script>
		<!-- DROPDOWN -->
		<script src="../js/dropdown.js"></script>
		<!-- TRANSITION -->
		<script src="../js/transition.js"></script>
		<!-- TOOLTIP -->
		<script src="../js/jquery.tooltipster.min.js"></script>
		<link href="../css/tooltipster.css" rel="stylesheet">
		<!-- DATATABLES -->
		<script src="../js/jquery.dataTables.js"></script>
		<!-- DATATABLES RESPONSIVE 
		<script src="../js/dataTables.responsive.js"></script>-->
		<!-- DATATABLES PLUGIN - DATE UK -->
		<script src="../js/date-uk.js"></script>
		<!-- DATATABLES PLUGIN - RELOAD AJAX -->
		<script src="../js/fnReloadAjax.js"></script>

		
		<script type="text/javascript">
		$(document).ready(function(){
			$('.tooltip').tooltipster({
	    		contentAsHTML: true,
	    		animation: 'grow'
			});
			var v_filtros='';

			$('#tabla').dataTable({
				"language": {"url": "../css/es_ES.txt"},
	    		"ajax": {
		            "url": "ajax_tabla_reservas.php",
		            "dataSrc": "",
		            "data": function ( d ) {
       					 d.action = 'getReservas',
       					 d.filtros = v_filtros
       				}
		        },
	        	"columns": [
	        		{ "data": "Estado" },		            
		            { "data": "Entrada" },
		            { "data": "Salida" },
		            { "data": "Noches" },
		            { "data": "Nombre" },
		            { "data": "Pais" },
		            { "data": "EMail" },
		            { "data": "Codigo" }

		        ],
		        "columnDefs": [
		        	{ 	"type": "date-uk", 
		        		"targets": 1
		        	},
		        	{ 	"type": "date-uk", 
		        		"targets": 2
		        	}
		        ],
		         "order": [[ 1, "desc" ]]
			});

			$('#filtros').on('change',function(e){
				var v_filtros='';
				if (!$('#cancelada').is(':checked'))				
					v_filtros+='c';
				if (!$('#vencida').is(':checked'))				
					v_filtros+='v';
				if (!$('#finalizada').is(':checked'))				
					v_filtros+='f';
				if (!$('#depopend').is(':checked'))				
					v_filtros+='p';
				if (!$('#depoparcial').is(':checked'))				
					v_filtros+='d';
				if (!$('#liquidada').is(':checked'))				
					v_filtros+='l';

				reload_reservas(v_filtros);
			});

			function reload_reservas(filtros){
				v_filtros=filtros;
				var table = $('#tabla').dataTable();
				table.fnReloadAjax();
			};		

			$('#tabla tbody').on( 'click', 'tr', function () {
		        var trid = $(this).closest('tr').attr('Id');
		        $('#principal').toggle(300);
				$('#adm-reserva').load('./adm_reserva.php?id='+trid).toggle(300);
				//$('#adm_reserva').fadeIn();
		    });

			$('#btn-menu').on('click',function(e){
				$(location).attr('href','./index.php');
			});

		});
 	</script>

	</head>
	<body class="panel">
		<div class="container">
			<div class="box-central">
				<div id="adm">
					<div class="row">
						<div class="col-xs-4">
							<h1>Administrar Reservas</h1>
						</div>
						<div class="col-xs-3">
							<div id="div-img">
							</div>
						</div>
					</div>
					<div id="principal">
						<div class="back-table">
						<div class="row back-table margin-top-1em">
							<table id="tabla" class="display responsive nowrap">
								<thead>
						            <tr>
						            	<th>Estado</th>
						                <th>Entrada</th>
						                <th>Salida</th>
						                <th>Noches</th>
						                <th>Nombre</th>
						                <th>País</th>
						                <th>Email</th>
						                <th>Código</th>
						            </tr>
						        </thead>
							</table>
						</div>
						<div id="filtros">
							<div class="panel panel-default">
								<div class="panel-heading">Filtrar Resultados</div>
								<div class="panel-body">
						    		<div class="row">
										<div class="col-xs-2">
											<label class="checkbox-inline">
												<input type="checkbox" id="cancelada" value="cancelada" checked>
												<img src="../img/panel/cancelada_table.png"/>
												<span style="display:inline;">Canceladas</span>
											</label>
										</div>
										<div class="col-xs-2">
											<label class="checkbox-inline">
												<input type="checkbox" id="vencida" value="vencida" checked>
												<img src="../img/panel/vencida_table.png"/>
												<span style="display:inline;">Vencidas</span>
											</label>
										</div>
										<div class="col-xs-2">
											<label class="checkbox-inline">
												<input type="checkbox" id="finalizada" value="finalizada" checked>
												<img src="../img/panel/finalizada_table.png"/>
												<span style="display:inline;">Finalizadas</span>
											</label>
										</div>
										<div class="col-xs-2">
											<label class="checkbox-inline">
												<input type="checkbox" id="depopend" value="depopend" checked>
												<img src="../img/panel/depopendiente_table.png"/>
												<span style="display:inline;">Pendiente de Dep&oacute;sito</span>
											</label>
										</div>
										<div class="col-xs-2">
											<label class="checkbox-inline">
												<input type="checkbox" id="depoparcial" value="depoparcial" checked>
												<img src="../img/panel/depositada_table.png"/>
												<span style="display:inline;">Con Dep&oacute;sito Parcial</span>
											</label>
										</div>
										<div class="col-xs-2">
											<label class="checkbox-inline">
												<input type="checkbox" id="liquidada" value="liquidada" checked>
												<img src="../img/panel/liquidada_table.png"/>
												<span style="display:inline;">Liquidada / Pagada</span>
											</label>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>
					</div>
					<div id="adm-reserva" style="display:none;"></div>
				</div>
				<div id="div-msg" class="margin-top-1em" style="display:none">
				</div>
				<div class="row margin-top-1em"><div class="col-xs-4 col-xs-offset-4"><button id="btn-menu" class="btn btn-lg btn-danger" style="width:90%">Volver al Men&uacute; Principal</button></div>
			</div>
			<div id="div-result">
			</div>
		</div>
	</body>
	<script type="text/javascript">

	</script>
</html>